<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta name="robot" content="index,follow">
<title>Module frc - Fraction module - Forth Foundation Library</title>
</head>
<body>
<h2>frc - Fraction module</h2>
<h3>Module Description</h3>
<p>The frc module implements a fraction data type. Note: to reduce normalizing
of fractions, the input is validated and normalized, but the resulting
output is NOT normalized. This is left to the next fraction word.
</p>
<h3>Module Words</h3>
<dl>
</dl>
<h4>Fraction structure</h4>
<dl>
<dt><a name="word1"><b>frc%</b>	( -- n )</dt>
<dd>Get the required space for a frc variable</dd>
</dl>
<h4>Fraction creation, initialisation and destruction</h4>
<dl>
<dt><a name="word2"><b>frc-init</b>	( frc -- )</dt>
<dd>Initialise the fraction to zero</dd>
<dt><a name="word3"><b>frc-create</b>	( "&lt;spaces&gt;name" -- ; -- frc )</dt>
<dd>Create a named fraction in the dictionary</dd>
<dt><a name="word4"><b>frc-new</b>	( -- frc )</dt>
<dd>Create a new fraction on the heap</dd>
<dt><a name="word5"><b>frc-free</b>	( frc -- )</dt>
<dd>Free the fraction from the heap</dd>
</dl>
<h4>General module words</h4>
<dl>
<dt><a name="word6"><b>frc+calc-gcd</b>	( n1 n2 -- +n )</dt>
<dd>Calculate the Greatest Common Divider</dd>
<dt><a name="word7"><b>frc+calc-lcm</b>	( n1 n2 -- +n )</dt>
<dd>Calculate the Least Common Multiplier</dd>
<dt><a name="word8"><b>frc+norm</b>	( n1 n2 -- n3 n4 )</dt>
<dd>Normalize a fraction n1/n2, return n3/n4</dd>
</dl>
<h4>Calculation module words</h4>
<dl>
<dt><a name="word9"><b>frc+add</b>	( n1 n2 n3 n4 -- n5 n6 )</dt>
<dd>Add two fractions n1/n2 and n3/n4, return n5/n6</dd>
<dt><a name="word10"><b>frc+subtract</b>	( n1 n2 n3 n4 -- n5 n6 )</dt>
<dd>Subtract fraction n3/n4 from fraction n1/n2, return n5/n6</dd>
<dt><a name="word11"><b>frc+multiply</b>	( n1 n2 n3 n4 -- n5 n6 )</dt>
<dd>Multiply fraction n1/n2 by fraction n3/n4, return n5/n6</dd>
<dt><a name="word12"><b>frc+divide</b>	( n1 n2 n3 n4 -- n5 n6 )</dt>
<dd>Divide fraction n1/n2 by fraction n3/n4, return n5/n6</dd>
<dt><a name="word13"><b>frc+invert</b>	( n1 n2 -- n3 n4 )</dt>
<dd>Invert the fraction n1/n2, return n3/n4</dd>
<dt><a name="word14"><b>frc+negate</b>	( n1 n2 -- n3 n4 )</dt>
<dd>Negate the fraction n1/n2, return n3/n4</dd>
<dt><a name="word15"><b>frc+abs</b>	( n1 n2 -- n3 n4 )</dt>
<dd>Absolute the fraction n1/n2, return n3/n4</dd>
</dl>
<h4>Conversion module words</h4>
<dl>
<dt><a name="word16"><b>frc+to-float</b>	( n1 n2 -- r )</dt>
<dd>Convert fraction n1/n2 to float value</dd>
<dt><a name="word17"><b>frc+to-string</b>	( n1 n2 -- c-addr u )</dt>
<dd>Convert fraction n1/n2 to a string using the pictured output area</dd>
</dl>
<h4>Compare module words</h4>
<dl>
<dt><a name="word18"><b>frc+compare</b>	( n1 n2 n3 n4 -- n )</dt>
<dd>Compare the fractions n1/n2 and n3/n4, return the result [-1,0,1]</dd>
</dl>
<h4>Structure words</h4>
<dl>
<dt><a name="word19"><b>frc-num@</b>	( frc -- n )</dt>
<dd>Get the numerator</dd>
<dt><a name="word20"><b>frc-denom@</b>	( frc -- n )</dt>
<dd>Get the denominator</dd>
<dt><a name="word21"><b>frc-get</b>	( frc -- n1 n2 )</dt>
<dd>Get the fraction n1/n2</dd>
<dt><a name="word22"><b>frc-set</b>	( n1 n2 frc )</dt>
<dd>Normalize and set the fraction n1/n2</dd>
<dt><a name="word23"><b>frc^move</b>	( frc2 frc1 -- )</dt>
<dd>Move frc2 in frc1</dd>
<dt><a name="word24"><b>frc^compare</b>	( frc2 frc1 -- n )</dt>
<dd>Compare fraction2 with fraction1, return the result [-1,0,1]</dd>
</dl>
<h4>Inspection</h4>
<dl>
<dt><a name="word25"><b>frc-dump</b>	( frc -- )</dt>
<dd>Dump the fraction</dd>
</dl>
<hr>
<div align="center">generated 24-Jul-2010 by <b>ofcfrth-0.10.0</b></div>
</body>
</html>
